<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>regist</title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.4/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$(".valitedEmail").hide();
		$(".valitedName").hide();
		$(".valitedPwd").hide();
		$(".valitedRepwd").hide();
		$(".flagEmail").hide();
		$(".flagName").hide();
		$(".flagPwd").hide();
		$(".flagRepwd").hide();
	});
</script>
<script type="text/javascript">
	function emailAjax(email) {
		$.ajax({
			type : "POST",
			url : "valitedEmail",
			data : ({
				email : email
			}),
			success : function(msg) {
				var f = $(msg).find(".flag").text();
				$(".valitedEmail").html($(msg).find(".valitedEmail"));
				if (f == "1") {
					$(".flagEmail").text("1");
					$(".valitedEmail span").css("color", "green");
					$(".valitedEmail").show();
				} else {
					$(".flagEmail").text("0");
					$(".valitedEmail span").css("color", "red");
					$(".valitedEmail").show();
					return false;
				}

			}
		});
	}

	function nameAjax(Name) {
		$.ajax({
			type : "POST",
			url : "valitedName",
			data : ({
				userName : Name
			}),
			success : function(msg) {
				$(".valitedName").html($(msg).find(".valitedName"));
				var f = $(msg).find(".flag").text();
				if (f == "1") {
					$(".flagName").text("1");
					$(".valitedName span").css("color", "green");
					$(".valitedName").show();
				} else {
					$(".flagName").text("0");
					$(".valitedName span").css("color", "red");
					$(".valitedName").show();
					return false;
				}

			}
		});
	}

	function pwdAjax(pwd) {
		$.ajax({
			type : "POST",
			url : "valitedPwd",
			data : ({
				pwd : pwd
			}),
			success : function(msg) {
				$(".valitedPwd").html($(msg).find(".valitedPwd"));
				var f = $(msg).find(".flag").text();
				if (f == "1") {
					$(".flagPwd").text("1");
					$(".valitedPwd span").css("color", "green");
					$(".valitedPwd").show();
				} else {
					$(".flagPwd").text("0");
					$(".valitedPwd span").css("color", "red");
					$(".valitedPwd").show();
					return false;
				}
			}
		});
	}
	function repwdAjax(repwd, pwd) {
		$.ajax({
			type : "POST",
			url : "valitedRepwd",
			data : ({
				repwd : repwd,
				pwd : pwd
			}),
			success : function(msg) {
				$(".valitedRepwd").html($(msg).find(".valitedRepwd"));
				var f = $(msg).find(".flag").text();

				if (f == "1") {
					$(".flagRepwd").text("1");
					$(".valitedRepwd span").css("color", "green");
					$(".valitedRepwd").show();
				} else {
					$(".flagRepwd").text("0");
					$(".valitedRepwd span").css("color", "red");
					$(".valitedRepwd").show();
					return false;
				}

			}
		});
	}

	function mySubmit(repwd, pwd, email, username) {

		repwdAjax(repwd, pwd);
		emailAjax(email);
		nameAjax(username);
		pwdAjax(pwd);
		var ef = $(".flagEmail").text();
		var nf = $(".flagName").text();
		var pf = $(".flagPwd").text();
		var rf = $(".flagRepwd").text();
		if (ef == "1" && nf == "1" && pf == "1" && rf == "1") {
			$("#reg").submit();
		} else {
			return false;
		}

	}
</script>
</head>
<body>
	<div class="content-top">
		<div class="wrap">

			<div class="section group">
				<div class="col span_2_of_contact">
					<div class="contact-form">
						<h3>学生注册</h3>
						<p class="flagEmail">0</p>
						<p class="flagName">0</p>
						<p class="flagPwd">0</p>
						<p class="flagRepwd">0</p>
						<p class="flag">${flag}</p>
						<form method="post" action="studentRegist" id="reg">

							<div>
								<span><label>E-Mail:</label></span> <span><input
									name="email" type="text" autocomplete="off"
									placeholder="请输入E-mail" onblur="emailAjax(email.value);"></span>
							</div>
							<div class="valitedEmail">
								<span style="color:red；"><label>${msg}</label></span>
							</div>
							<div>
								<span><label>姓名:</label></span> <span><input
									name="userName" type="text" autocomplete="off"
									placeholder="请输入您的真实姓名" onblur="nameAjax(userName.value);">
								</span>
							</div>
							<div class="valitedName">
								<span><label>${msg}</label></span>
							</div>
							<div>
								<span><label>密码:</label></span> <span><input name="pwd"
									type="password" class="textbox" placeholder="请输入密码"
									onblur="pwdAjax(pwd.value);"></span>

							</div>
							<div class="valitedPwd">
								<span><label>${msg}</label></span>
							</div>
							<div>
								<span><label>确认密码:</label></span> <span><input
									name="repwd" type="password" class="textbox"
									placeholder="请确认输入密码"
									onblur="repwdAjax(repwd.value,pwd.value);"></span>
							</div>
							<div class="valitedRepwd">
								<span><label>${msg}</label></span>
							</div>
							<div>
								<span> <input type="button" value="提交"
									onclick="mySubmit(repwd.value,pwd.value,email.value,userName.value);" />
								</span>
							</div>
						</form>
					</div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
	</div>
	<div style="height: 150px;"></div>
</body>
</html>



